package cn.itcast.wushangxiantu.BaseAdapter;

import android.content.Context;
import android.content.res.Resources;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import cn.itcast.wushangxiantu.R;

public class ChongWuTuJianAdatper extends BaseAdapter {
    private Context context;
    public List<String> chongwuName = new ArrayList<>();
    public List<String> chongwuShuoMing = new ArrayList<>();
    public List<String> djmax = new ArrayList<>();
    private String chongwu[];
    private ViewHolder viewHolder;
    private int i;

    public ChongWuTuJianAdatper(Context context) {
        this.context = context;
        Resources res = context.getResources();
        chongwu = res.getStringArray(R.array.chongwu);
        for (int i = 1; i < chongwu.length; i++) {
            chongwuName.add(chongwu[i]);
        }
        chongwu = res.getStringArray(R.array.chongwumaxdj);
        for (int i = 1; i < chongwu.length; i++) {
            djmax.add(chongwu[i]);
        }
        chongwu = res.getStringArray(R.array.chongwushuoming);
        for (int i = 1; i < chongwu.length; i++) {
            chongwuShuoMing.add(chongwu[i]);
        }
    }

    @Override
    public int getCount() {
        return chongwuName.size();
    }

    @Override
    public Object getItem(int i) {
        return chongwuName.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = View.inflate(context, R.layout.adapter_youxiang, null);
            viewHolder = new ViewHolder(view);
        viewHolder.tvHand.setText(chongwuName.get(i));
        viewHolder.tvTime.setText("满级" + djmax.get(i));
        viewHolder.tvContent.setText("技能：" + chongwuShuoMing.get(i));
        return view;
    }

    class ViewHolder {
        public View rootView;
        public TextView tvHand;
        public TextView tvTime;
        public TextView tvContent;

        public ViewHolder(View rootView) {
            this.rootView = rootView;
            this.tvHand = (TextView) rootView.findViewById(R.id.tvHand);
            this.tvTime = (TextView) rootView.findViewById(R.id.tvTime);
            this.tvContent = (TextView) rootView.findViewById(R.id.tvContent);
        }

    }
}
